package utils;

import java.io.UnsupportedEncodingException;
import java.util.Base64;

public final class Base64Util {
	private static final String ENCODING = "UTF-8";
	private Base64Util(){
	}
	//Base64算法
	public static String base64Encoding(byte[] data)  {
		return Base64.getEncoder().encodeToString(data);
	}

	public static String base64Encoding(String text) throws UnsupportedEncodingException {
		return Base64.getEncoder().encodeToString(text.getBytes(ENCODING));
	}

	public static byte[] base64Decoding(String text) {
		return Base64.getDecoder().decode(text);
	}

	public static String base64DecodingS(String text)  throws UnsupportedEncodingException {
		return new String(Base64.getDecoder().decode(text), ENCODING);
	}
}
